package com.mmy.service.plane.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mmy.dao.plane.TPlaneOrderRepository;
import com.mmy.dao.plane.VPlaneOrderRepository;
import com.mmy.domain.plane.TPlaneOrder;
import com.mmy.domain.plane.VPlaneOrder;
import com.mmy.service.plane.TPlaneOrderService;

@Service

public class TPlaneOrderServiceImpl implements TPlaneOrderService {

	@Autowired
	TPlaneOrderRepository tPlaneOrderRepository;
	@Autowired
	VPlaneOrderRepository vPlaneOrderRepository;

	/**
	 * 获取最大流水号
	 * 
	 * @return 返回值说明 流水号
	 * @author 创建人 dingxd
	 * @date 创建日期 2020.11.17
	 */
	public int getMaxID() {
		// 流水号
		Object objCode = tPlaneOrderRepository.getMaxID();
		int iID = 0;
		if (objCode != null) {
			iID = Integer.parseInt(objCode.toString());
		}
		return iID;
	}

	/**
	 * 获取订单最大编码
	 * 
	 * @param 参数说明 计划单编码
	 * @return 返回值说明 订单编码
	 * @author 创建人 dingxd
	 * @date 创建日期 2020.11.17
	 */
	public String getMaxCode(int iPlanID) {
		// int 转 string
		String strPlanID = String.valueOf(iPlanID);
		// 返回订单最大编码
		Object objCode = tPlaneOrderRepository.getMaxCode(strPlanID);
		String strCode = "";
		if (objCode != null) {
			strCode = objCode.toString();
		}
		return strCode;
	}

	/**
	 * 新增id
	 * 
	 * @param
	 * @return
	 */
	public void save(int id) {
		// TODO Auto-generated method stub
		tPlaneOrderRepository.save(id);
	}

	/**
	 * 新增
	 * 
	 * @param
	 * @return
	 */
	public void save(TPlaneOrder tPlaneOrder) {
		// TODO Auto-generated method stub
		tPlaneOrderRepository.save(tPlaneOrder);
	}

	/**
	 * 通过id查找
	 * 
	 * @param
	 * @return
	 */
	public TPlaneOrder findByID(int iID) {
		// TODO Auto-generated method stub
		return tPlaneOrderRepository.findByID(iID);
	}

	/**
	 * 通过id查找
	 * 
	 * @param
	 * @return
	 */
	public List<VPlaneOrder> findByPlaneID(int iPlaneID) {
		// TODO Auto-generated method stub
		return vPlaneOrderRepository.findByPlaneID(iPlaneID);
	}

	/**
	 * 删除预留
	 * 
	 * @param
	 * @return
	 */
	public void delPlaneOrder(List<Integer> lstID) {
		// TODO Auto-generated method stub
		tPlaneOrderRepository.delPlaneOrder(lstID);
	}

	/**
	 * 出纳查询
	 * 
	 * @param
	 * @return
	 */
	public List<VPlaneOrder> findByCashierAndPlaneID(String strCashierState, int iPlaneID) {
		// TODO Auto-generated method stub
		return vPlaneOrderRepository.findByCashierAndPlaneID(strCashierState, iPlaneID);
	}

	/**
	 * 查全部
	 * 
	 * @param
	 * @return
	 */
	public List<VPlaneOrder> findAll() {
		// TODO Auto-generated method stub
		return vPlaneOrderRepository.findAll();
	}

	/**
	 * 会计查询
	 * 
	 * @param
	 * @return
	 */
	public List<VPlaneOrder> findByAccountAndPlaneID(String strAccountState, int iPlaneID) {
		// TODO Auto-generated method stub
		return vPlaneOrderRepository.findByAccountAndPlaneID(strAccountState, iPlaneID);
	}

	public void saveAll(List<TPlaneOrder> lstCashier) {
		// TODO Auto-generated method stub
		tPlaneOrderRepository.saveAll(lstCashier);
	}

	/* 个人中心通过登录人获取机票预留 */
	public List<TPlaneOrder> findByUserID(int userID) {
		// TODO Auto-generated method stub
		// return tPlaneOrderRepository.findByUserID(userID);
		return null;
	}

	/* 个人中心通过登录人获取机票订单 */
	public List<TPlaneOrder> findByOrderUserID(int userID) {
		// TODO Auto-generated method stub
		// return tPlaneOrderRepository.findByOrderUserID(userID);
		return null;
	}

	/* 个人中心通过登录人获取机票退单 */
	public List<TPlaneOrder> findByChargeBackUserID(int userID) {
		// TODO Auto-generated method stub
		// return tPlaneOrderRepository.findByChargeBackUserID(userID);
		return null;
	}

}
